home *** CD-ROM | disk | FTP | other *** search
/ JCSM Shareware Collection 1996 September / JCSM Shareware Collection (JCS Distribution) (September 1996).ISO / prgtools / disas.zip / README.TXT < prev    next >
Text File  |  1994-05-01  |  19KB  |  536 lines

  1.  
  2.               _______
  3.          ____|__     |               (R)
  4.       --|       |    |-------------------
  5.         |   ____|__  |  Association of
  6.         |  |       |_|  Shareware
  7.         |__|   o   |    Professionals
  8.       -----|   |   |---------------------
  9.            |___|___|    MEMBER
  10.  
  11.  
  12.  
  13.  
  14.  
  15.  ABOUT SHAREWARE
  16.  
  17.      This package contains the disassembler named DISASTER.  It
  18. is made by
  19.      Feico Nater, 
  20.      Beukweg 24, 
  21.      7556 DE Hengelo,
  22.      the Netherlands.
  23.  
  24.  
  25.      The system is available as shareware.  What is shareware? 
  26. It is software which people pass around, but I, the author,
  27. retain the rights to it.  Maybe you obtained the system from a
  28. bulletin-board and paid a few dollars for it, but I don't get a
  29. penny of it.  I expect to be paid by you, because I make my
  30. living out of making shareware software.
  31.   Therefore, if you like this system and use it, you are supposed
  32. to register by sending a US$50 bill (or an equal amount in
  33. another reasable currency).  Sorry, I can accept neither checks
  34. nor credit-cards.  The address:  Feico Nater Shareware, Beukweg
  35. 24, 7556 DE Hengelo, the Netherlands.
  36.      Why register?  Well, it costs you money.  But if you do, I
  37. will advise you about further developments. Furthermore you will
  38. have the right to order later versions for only a few dollars and
  39. I will be willing to listen to your wishes.
  40.      And if you don't like the system?  Well, throw it away.  But
  41. you will like shareware, because it does not let you pay a lot
  42. of money for something you dislike afterwards.
  43.      Whether you register or not, you are encouraged to pass this
  44. system around.  Give away copies to your friends.  However, files
  45. with the extension .NAR should not be given away.  The copies you
  46. pass around must be complete and unmodified, but file-compression
  47. is allowed.  Any money you collect should be for diskette,
  48. packing, postage only and should not exceed five dollars.
  49.  
  50. ABOUT THE AUTHOR
  51.  
  52.      I have been working with computers since 1970.  I have
  53. completed a third-level degree in computer-science.  I have been
  54. employed for many years in a big company, making defense-
  55. equipment, and my colleagues considered me the most skilled
  56. programmer among them.  However, since the company went broke
  57. (Gorbachev was to blame, and he did a good job) I became
  58. unemployed and started woring as a shareware author.
  59.  
  60. *******************************
  61. *       D I S A S T E R       *
  62. *******************************
  63.  
  64.  
  65. INTRODUCTION
  66.  
  67.   Disaster is an interactive disassembler for the IBM-PC.
  68.  
  69.   A disassembler is not something special.  The program DEBUG,
  70. which is part of MSDOS, contains a disassembler.  But DEBUG knows
  71. only the 8086 and 8088.  The program CODEVIEW, which is part of
  72. MASM, also contains a disassembler that can handle all 80486
  73. machine instructions.  But neither DEBUG nor CODEVIEW produce no
  74. coding which can be used as input to an assembler.
  75.  
  76.   The ideal disassembler would work simply.  It would read the
  77. machine language program and translate everything into assembly
  78. language, knowing what is code and what is data.  However, no
  79. actual disassembler produces a neat assembly-language program at
  80. once.  Instead, disassembling a program takes many days of labor.
  81.  
  82.   The simplest conceivable disassembler works straightforward. 
  83. It reads the machine-language program and translates everything
  84. into assembly-language, no matter whether it is code or data.
  85.  
  86.   Disaster works interactively.  You can inspect the program, add
  87. labels and comments, indicate what is code and what is data.  The
  88. result can be saved so you can continue the next day.  Eventually
  89. DISASTER makes a neat assembly-language program.
  90.  
  91.   This manual is very short.  There is little to tell.  Knowledge
  92. of the PC and its assembly-language is presumed.
  93.  
  94.  
  95. COMMAND SUMMARY (labels are allowed for any address)
  96. ; address,comment          supply comments preceding an address
  97. ; address,-                delete a comment
  98. A address,address          automatic label generation
  99. B address,address          automatic control and label generation
  100. C address,letter           indicate code or data
  101. C address,-                delete a control
  102. F ????                     find word
  103. L address,label            provide a label
  104. L address,-                delete a label
  105. L old-name,new-name        replace a label
  106. Q                          quit, or close creation of output-file
  107. R progname                 read a program
  108. S                          write a script-file
  109. U address,address          unassemble
  110. W                          create output-file
  111.   DEMONSTRATION
  112.  
  113.  
  114.   The first time DISASTER is started with the DOS command:
  115.           DISASTER
  116.   You will see an error message which you can ignore.  The prompt
  117. --> indicates that DISASTER expects your commands.
  118.  
  119.   Now read a program with the command:
  120.           R name.EXE          
  121. or:
  122.           R name.COM
  123. or:
  124.           R name.SYS
  125.  
  126.   If you want to disassemble something that is already in memory,
  127. then you enter:
  128.           R segment-address.ROM
  129.  
  130.   Now you must tell that the program must be disassemble as code. 
  131. The command is (exactly this):
  132.           C LSTARTLOCATION,I
  133.   That's a long command, but LSTARTLOCATION is simply a label in
  134. your program.
  135.   Now start disassembling!  Enter the command: 
  136.           U LSTARTLOCATION
  137. and you will see a piece of disassembled program on the screen..
  138. To the left you see the addresses, next the mnemonic codes, and
  139. to the right (in color) the original machine language.  A green
  140. block indicates that no valid opcode was found. Prefixes will be
  141. yellow, opcodes green, modrm-bytes and sib-bytes red, operands
  142. blue.
  143.  
  144.   Different U-commands are:
  145.      U address             disassembles 20 lines from ...
  146.      U address,address     disassembles from .. to ..
  147.      U                     disassembles next 20 lines
  148.      <return>              same
  149.  
  150.   Addresses in commands are always hexadecimal.  Instead of
  151. addresses you can enter labels (see below).
  152.  
  153.  
  154.   HELP
  155.  
  156.   Help texts are available with the keys F5 through F10.  Any key
  157. removes the help text.  F1 and F3 can be used to repeat a
  158. command, just as in COMMAND.COM, and Insert, Delete and Backspace
  159. keys may be used with F1 and F3.
  160.  
  161.  
  162.   LABELS
  163.  
  164.  
  165.   All adresses will be hexadecimal.  Of course you prefer labels.
  166. That can be arranged with the command:
  167.      L address,label
  168.  
  169.   As usual in programming languages, a label must start with a
  170. letter.  Furthermore it must contain at least once the letter G
  171. thru Z.  The maximum length is fourteen characters.
  172.  
  173.   If a label does not contain any of the letters G thru Z, then
  174. DISASTER will assume it is a hexadecimal address.
  175.  
  176.   Be careful when using labels which start with the letter L. 
  177. The function that generates controls assumes that such a label
  178. is followed by instruction-code.
  179.  
  180.   Labels may be used in commands.  The U commando could be: 
  181.      U label,label.  
  182.  
  183.   Labels can be removed with the command:
  184.      L label,-
  185. or:
  186.      L adress-             
  187.  
  188.   Labels can be renamed with the command:
  189.      L old-name,new-name
  190.  
  191.   Two labels cannot be at the same address.
  192.  
  193.   The maximum number of labels is 4090.
  194.  
  195.  
  196.   INITIALLY ENTERED LABELS
  197.  
  198.   If you read a file, Disaster will automatically generate some
  199. labels in the header - PSP area.  Most labels begin with the
  200. later Z.  There is also a label named LSTARTLOCATION, and that
  201. is the address where execution starts.  
  202.  
  203.  
  204.   RELATIVE LABELS
  205.  
  206.   A new feature in version 1.3 is relative labels.  A relative
  207. label ends in + or - .  Here's an example:
  208.   L3E4,stuff
  209.   L3E8,stuff+
  210.   L3E2,stuff-
  211.   This defines a common label at address 3E4 and two relative
  212. labels at adddresses 3E8 and 3E2.  In the disassembly, the
  213. relative labels will be displayed as STUFF+4 and STUFF-2.
  214.   Note that several relative labels may have the same name. 
  215. Furthermore there must be a common label with the same name as
  216. the relative label, but with the + or - removed.  If there is no
  217. such label, Disaster will not be able to disassemble your program
  218. correctly.
  219.  
  220.   CONTROLs
  221.  
  222.  
  223.   Not everything is instruction-code.  There is also data.  The
  224. disassembler cannot easily tell the difference.  And what's more,
  225. there are different kinds of code and data.  Therefore you must
  226. tell DISASTER what is code and what is data and what kind it is. 
  227. This is done with the command:
  228.      C address,letter(s)
  229. or:
  230.      C label,letter(s)
  231.  
  232.   A control can be removed by:
  233.      C address,-
  234. or:
  235.      C label,-
  236.  
  237.   At any address, disassembly is controlled by the most recent
  238. control letter. 
  239.  
  240.   The letter(s) can be:
  241.      B hexadecimal bytes
  242.      T text in quotes, when possible
  243.      W hexadecimal words
  244.      I instruction-code for Intel chips
  245.      IV instruction-code for NEC V20 of V30
  246.      IA instruction-code for 80386 in protected mode with address 
  247. and operand length of 32 bits.
  248.  
  249.   B, T and W are data-controls, the others are code-controls. 
  250. This distinction is important for the A- and B-commands, which
  251. will be discussed below.  
  252.   The controls chop your program into sections.  There are data-
  253. sections and code-sections.
  254.  
  255.   If DISASTER encounters an opcode that is valid on a NEC-chip
  256. but not on a Intel-chip, or vice versa, then DISASTER will just
  257. disassemble it.  Whether I of IV was given is not important.  But
  258. there are opcodes which have a different meaning on NEC- and
  259. Intel-chips.  In that case I or IV decides what to do.  Programs
  260. with these opcodes are rare.
  261.  
  262.   IA can only be used in programs which are intended to run on
  263. a 80386 in protected mode.  In real mode the addresses and
  264. operands default to 16 bits.
  265.  
  266.   The maximum number of controls is 16380.
  267.  
  268.  
  269.  
  270.   INITIALLY ENTERED CONTROLS
  271.  
  272.   If you read a file, DISASTER will automatically generate some
  273. controls in the header.  Without the header the initial control
  274. is T.  That seems strange, it is done because the correct
  275. controls are not yet known, and to make it easy to recognise
  276. readable text.
  277.  
  278.  
  279.  
  280.   AUTOMATIC LABEL GENERATION
  281.  
  282.   Manually entering labels and controls is a very tedious job. 
  283. DISASTER can help you.
  284.  
  285.   Labels will be generated with the command:
  286.      A address,address
  287.   
  288.   DISASTER now searches your program, at the same time showing
  289. a listing.  Only code-sections will be searched, data-sections
  290. will be skipped.  Each time DISASTER encounters an address-
  291. reference a label will be entered.
  292.   This label will look like: L45A3_27E5.
  293.   The first letter op de label indicates the kind of reference: 
  294.      L branch instruction
  295.      W word data
  296.      T byte data
  297.  
  298.   That first letter is followed by the hexadecimale address the
  299. label refers to.  This guarantees that all labels are distinct. 
  300. It is followed by an underscore and the address where the
  301. reference was encountered for the first time.  This facilitates
  302. surveying the program.
  303.  
  304.   Whenever a label is generated DISASTER will show a white block
  305. on the screen.  Therefore this block is shown in every JMP- and
  306. every CALL-instruction and in every memory-reference where there
  307. was no label yet.
  308.  
  309.  
  310.  
  311.   AUTOMATIC CONTROL GENERATION
  312.  
  313.   Controls and labels will automaticaly be generated with the
  314. command
  315.      B address,address
  316.  
  317.   DISASTER now searches the labels of your program.  Whenever
  318. DISASTER encounters a label in a data-section which begins with
  319. an L, a control I will be generated, causing the next part of the
  320. program to be interpreted as code.  At the next unconditional
  321. RET- or JMP-instruction another control will be generated to
  322. restore the previous situation.
  323.  
  324.   Whenever a control will be generated DISASTER will show a white
  325. block on the screen.  Therefore this blok will be shown:
  326.   1 at every label that begins with an L and occurs in a data-
  327. section.
  328.   2 at the first RET- or JMP-instruction afterwards.
  329.  
  330.   Furthermore, whenever a control I is generated, that bit of
  331. coding will be searched for address-references to generate labels
  332. (as described in the previous chapter).
  333.  
  334.  
  335. USING THE MOUSE
  336.  
  337.   You may want to enter a label or a control at some place in
  338. your program, but you don't know the exact address.  For example,
  339. the disassembly contains the line:
  340. 0357   DB 'Press any key',0,'Invalid command'
  341.   You 'd want to insert a label at the letter I.  Now type L,
  342. take the mouse and click with the left button on the letter I. 
  343. The address is inserted on the command line.  Now complete the
  344. command.
  345.   Whenever you click with the left button on any part of the
  346. disassembly, the address of that point is inserted on the command
  347. line, just as if you had typed it.  If you click the right
  348. button, the number or name you clicked on is inserted.
  349.   The left button is a bit buggy: it will not work when there is
  350. a line wrap in the disassembly.  Such line wraps do not often
  351. occur.
  352.  
  353.  
  354.   HINTS
  355.  
  356.    Usually a disassembly starts like this:
  357.  
  358.   C:\disaster              Start DISASTER 
  359.   --->Rprogr.com           read the program
  360.   --->B100,ffff            generate labels and controls
  361.   --->B100,ffff
  362.   --->B100,ffff
  363.   --->B100,ffff
  364.  
  365.   You will see that more and more labels and code-controls will
  366. appear.
  367.  
  368.   The command B100,ffff can easily be repeated with the F3-key.
  369. Repeat it until DISASTER reports that no more labels and controls
  370. were added.
  371.  
  372.   If you are lucky this has almost completed disassembly, and you
  373. hardly did anything!  How many other disassemblers will do that
  374. for you?
  375.  
  376.   Is there anything to go wrong?  Alas, nothing is perfect, for
  377. example in these cases:
  378. 0150 JNZ L0123
  379. 0152 JZ  L0156
  380. 0154 ADD B[BX+SI],AL
  381.   The B-command thinks that the instruction at 0154 is code,
  382. since it is not preceded by a unconditional jump.  But JNZ and
  383. JZ taken together are unconditional, and the instructions from
  384. 0154 and further should be data.  If there are, beyond 0154,
  385. things which look like instructions with address-references, then
  386. there will be false labels.
  387.   If you watch while the B-command is executing, then you will
  388. see this happen.  Interrupt the command with any key, search for
  389. the right spot and enter a data-control at address 0154.
  390.  
  391.      INT 020
  392.   This is the end of the program, just like INT 021 with AH=00
  393. or 04C.  The B-command does not recognize it
  394.  
  395.      JMP [08170+BX]
  396.   This is a branch through a table of branch-addresses.  DISASTER
  397. does not recognize this.  You must give labels to the addresses
  398. in the table.  Use labels which begin with the letter L, so the
  399. B-command will treat it as code. 
  400.  
  401.  
  402.  
  403.   COMMENTS
  404.  
  405.   You can enter comments with the command:
  406.      ;address,text
  407. or, of course:
  408.      ;label,text
  409.  
  410.   Note the semicolon that is the first character of this command.
  411.  
  412.   Comments can be removed with:
  413.      ;address,-
  414. or:
  415.      ;label,-
  416.  
  417.   Comments will be output preceding the addressed line. When
  418. control is B, T or W, a comment causes a line break.  A comment
  419. halfway a word constant or halfway an instruction will not be
  420. output.
  421.  
  422.   The backslash \ has a special meaning in a comment.  It
  423. produces a new line, so a comment can span several lines.  Two
  424. backslashes at the beginning of a comment produce a new page.
  425.  
  426.      ;address,single line comment
  427.      ;address,\single line preceded by blank line
  428.      ;address,\\first line on a page\second line 
  429.  
  430.   The maximum length of a comment is 127 bytes.
  431.  
  432.   There can be no two comments on one address.
  433.  
  434.   The maximum amount of commentary is about 62500 bytes, plus
  435. some overhead.
  436.  
  437.   Sorry, comments cannot be edited.  But you can edit the SCR
  438. file with a text editor.
  439.  
  440.  
  441.   INTERRUPTING AND CONTINUING
  442.  
  443.  
  444.   You have worked some time and entered many labels, controls and
  445. comments.  You want to go on the next day.  This is done with the
  446. command:
  447.      S
  448.   DISASTER now writes a script-file.  This file has extensie .SCR
  449. and, unless you gave another name, the same name as your program.
  450.  
  451.   If the script-file exists, DISASTER will ask you to confirm.
  452.  
  453.   Eventually stop with the command:
  454.      Q
  455.   When no script-file has been made. DISASTER will ask you to
  456. confirm.
  457.  
  458.   To continue the next day start the disassembler with the
  459. command:
  460.      DISASTER filename
  461. entering the name of the script-file.
  462.  
  463.   A script-file is an ASCII-file containing commands for the
  464. disassembler.  Feel free to modify this file with a text-editor. 
  465.  The commands do not need to be sorted and do not need to be in
  466. upper case.  Disaster will convert to upper case (except
  467. comments) and sort the commands as it loads them from the script-
  468. file or keyboard input.
  469.  
  470.  
  471.   OPTIONS
  472.  
  473.   Certain settings of the disassembler can be changed.  An option
  474. can be set by entering the letter O, followed by a letter
  475. describing which option you want to set.  An option can be turned
  476. off by entering the letter O, followed by a letter describing
  477. which option you want to set, followed bu a comma and a hyphen. 
  478. The following options are available.
  479.  
  480. OP   memory reference preceded by B, W or D 
  481. OP,- memory reference preceded by BYTE PTR or (D)WORD PTR 
  482. OL   output code labels on a separate line
  483. OL,- output labels and code on the same line
  484. OA   output addresses to file and screen
  485. OA,- output addresses to screen only
  486. OH   hexadecimal values are preceded by a zero when the initial
  487. digit would otherwise be A through F, and they are followed by
  488. the letter h.
  489. OH,- hexadecimal values are always preceded by a zero and not
  490. followed by h.
  491. OO   implicit operands after XLAT, MOVS, OUTS, SCAS and similar
  492. instructions are always output.
  493. OO,- implicit operands are output only when there is a segment
  494. override.
  495.  
  496. Press F10 to see the current settings of the options.
  497.  
  498.  
  499.   MAKING A SOURCE-FILE
  500.  
  501.  
  502.   Eventually you'll want to produce a source-file.  This source-
  503. file can be re-assembled with an assembler, such as Eric
  504. Isaacson's A86.  The source-file is opened with the command:
  505.      W
  506.   The source-file has the same name as the .SYS-, .EXE- or .COM-
  507. file, but the extension is .8.
  508.  
  509.   As long as the source-file is open the prompt is >>>.  The only
  510. legal commands now are O, U and Q.  So it is possible to change
  511. an option while writing the output file.
  512.  
  513.   After the command W you will enter one or more U-commands.  You
  514. will only see the addresses on the screen, the disassembled text
  515. goes to the file.
  516.  
  517.   Eventually close the file with the command:
  518.      Q
  519. This redisplays the prompt -->.
  520.  
  521.   Perhaps you expect that assembling the source-file should
  522. produce the same .COM- of .EXE-file again.  Actually many machine
  523. instructions have the same mnemonic code, such as:
  524.   MOV AX,BX                8BC3 of 89D8
  525.   REP MOVSB                F3A4 of F2A4
  526.   ADD BX,5                 83C305 of 81C30500
  527.   JMP $+8                  EB06 of E90500
  528.  
  529.   Furthermore some instructions are conceivable but not
  530. acceptable to the processor, such as SHL AL,30 of BOUND AX,BX. 
  531. DISASTER accepts these, the assembler may refuse them.
  532.  
  533.  
  534.  
  535.  
  536.